
$(document).ready(function(){
	var Main = {
			created(){
				this.getMenus();
				this.getSigns();
				this.getTpzlList();
				this.getTzggList();
				this.getSxtzList();
				this.getKjdtList();
				this.getGbList();
				this.getGsList();
				this.getKjjsList();
				this.getZcfgList();
				this.getTeaActivityList();
			},
			filters:{
				formateDate(time){
					return new Date(time).Format("yyyy-MM-dd");
				}
			},
		    data () {
				return {
					menuList: [
						{
							label: "项目与活动管理",
							value: "M01",
							path: "",
							children: [
								{
									label: "教育科普项目",
									value: "xiangmushenbao",
									path: "https://kpg.gzjkw.net/kpsb/login.zul?service=http://kpg.gzjkw.net/kpsb/security_check",
								},
								{
									label: "竞赛活动",
									value: "kejitiyu",
									path: "",
									children: [
										{
											label: "科技体育",
											value: "kejitiyu",
											path: "https://kpg.gzjkw.net/innovateActivityPage/#/forward/sportsActivities/activityIndex",
										},
										{
											label: "创新创业大赛",
											value: "chuangxindasai",
											path: "https://kpg.gzjkw.net/innovateActivityPage/#/forward/innovationActivities/activityIndex",
										},
									],
								},
								{
									label: "实践探究",
									value: "",
									path: "",
									children: [
										{
											label: "夏令营",
											value: "xialingying",
											path: "https://kpg.gzjkw.net/innovateActivityPage/#/forward/activityIndex",
										},
									],
								},
							],
						},
						{
							label: "数据与资料管理",
							value: "M02",
							path: "",
							children: [
								{ label: "科教之窗", value: "", path: "" },
								{ label: "绿色学校", value: "lvsexuexiao", path: "https://kpg.gzjkw.net/lsxxPage/#/login?redirect=%2F" },
								{ label: "垃圾分类", value: "lajifenlei", path: "https://kpg.gzjkw.net/wastePage/#/login?redirect=%2F" },

								{
									label: "证书管理",
									value: "",
									path: "",
									children: [
										{ label: "广州市教育局电子证书系统", value: "", path: "https://kpg.gzjkw.net/zs/" },
										{ label: "科技类证书登记与核对", value: "", path: "https://kpg.gzjkw.net/kjjsdjPage/login" },
									],
								},
								{ label: "业务工作资料", value: "", path: "" },
							],
						},
						{
							label: "科教资源",
							value: "M03",
							path: "",
							children: [],
						},
					],
					nowDate:new Date().getTime(),
					interfaceUrl:"http://127.0.0.1:8089/innovateActivity",
					signUpUrl:"http://127.0.0.1:8087/#/teaActivity/teaSignUp",
					signUpBackUrl:"http://127.0.0.1:8087/",
					ctx:ctx,
					kpgmh:kpgmh,
					teaActivityList:[],
					zcfg_list:[],
					gs_list:[],
					gb_list:[],
					tzgg_list:[],
					kjjs_list:[],
					sxtz_list:[],
					kjdt_list:[],
					activity_list:[],
					tpzl_list:[],
					xiangmu_list:[],
					jiaoshiActivities:[],
					jiGous:[],
					menus:[],
					zcfg:"",
					tzgg:"",
					gs:"",
					gb:"",
					kjjs:"",
					sxtz:"",
					kjdt:"",
					userType:userType,
					kpsbcrac:kpsbcrac,
					kpsbsecurbm:kpsbsecurbm
				}
			},
			methods:{
				getSigns(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getSigns.do",
						data: {pageSize:5},
						success: function(data) {
							that.xiangmu_list = data.xiangmus;
							that.activity_list = data.activities;
							that.jiaoshiActivities = data.jiaoshiActivities;
							that.jiGous = data.jiGous;
							that.$nextTick(function(){
								let aLi = $(".hdul").children();
								$.each(aLi, function(index, term){
									term.onmouseover = function(){
										$(this).children("a").eq(1).children("img").attr("src","images/first/baomingselect.png");
										$(this).children("img").attr("src","images/first/3_0000.png");
									}
									term.onmouseleave = function(){
										$(this).children("a").eq(1).children("img").attr("src","images/first/baomin.png");
										$(this).children("img").attr("src","images/first/3_0001.png");
									}
								});

								aLi = $(".jshdul").children();
								$.each(aLi, function(index, term){
									term.onmouseover = function(){
										$(this).children("a").eq(1).children("img").attr("src","images/first/baomingselect.png");
										$(this).children("img").attr("src","images/first/3_0000.png");
									}
									term.onmouseleave = function(){
										$(this).children("a").eq(1).children("img").attr("src","images/first/baomin.png");
										$(this).children("img").attr("src","images/first/3_0001.png");
									}
								});

								aLi = $(".xmul").children();
								$.each(aLi, function(index, term){
									term.onmouseover = function(){
										$(this).children("a").eq(1).children("img").attr("src","images/first/xmbaomingselect.png");
										$(this).children("img").attr("src","images/first/3_0000.png");
									}
									term.onmouseleave = function(){
										$(this).children("a").eq(1).children("img").attr("src","images/first/xmbaomin.png");
										$(this).children("img").attr("src","images/first/3_0001.png");
									}
								});
								
								let aDiv = $("#top_title").children();
								$.each(aDiv, function(index, term){
									term.onclick = function(){
										$(this).siblings("div").removeClass("active");
										$(this).addClass("active");
										if(index == 1){
											$(".xmul").show();
											$(".hdul").hide();
											$(".jshdul").hide();
											$("#gmore").attr("href",that.ctx+"/getMoreXm.do?pageIndex=1")
										}else if(index == 0){
											$("#gmore").attr("href",that.ctx+"/getMore.do?pageIndex=1");
											$(".hdul").show();
											$(".xmul").hide();
											$(".jshdul").hide();
										}else{
											$(".jshdul").show();
											$(".xmul").hide();
											$(".hdul").hide();
										}
									}
								});
							});
						}
					});
				},
				getMenus(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getMenus.do",
						data: {},
						success: function(data) {
							that.menus = data.menus;
							that.$nextTick(function(){
								let liLength = $(".common_menu").length;
								let bfb = (100/liLength).toFixed(2)+"%";
								$(".common_menu").css('width',bfb);
							});
						}
					});
				},
				getTeaActivityList(){
					let that = this;
					$.ajax({
						type: "get",
						url: that.interfaceUrl + "/tea/activity/list?pageNum=1&pageSize=10&isPublic=1",
						success: function(data) {
							that.teaActivityList = data.rows;
							console.log(that.teaActivityList,'teaActivityList');
						}
					});
				},
				getZcfgList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:46,pageSize:5},
						success: function(data) {
							that.zcfg_list = data.news_list;
							that.zcfg = data.menu;
						}
					});
				},
				getTpzlList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:36,pageSize:5},
						success: function(data) {
							that.tpzl_list = data.news_list;
							that.$nextTick(function(){
								var obj = $("#slideBox");
								var effect = "effect-z1";
								var btns = obj.find(".hd li");
								var con = obj.find(".bd ul");
								var size = con.find("li").size();
								var curIndex = 0;
								var w = obj.width();
								var h = obj.height();
								var sliceNum=8;
								var running = true;
									
								obj.find(".bd li").each(function(n){
									$(this).css({"position":"absolute","top":"0","left":"0","z-index":size-n});
								});

								//鼠标事件
								btns.click(function(){
									if(!running){ return false; }
									curIndex = btns.index($(this));
									$(this).addClass("on").siblings().removeClass("on");
									con.find(".slideClone").remove();
									doEffect(curIndex);
								});



								setInterval(function(){
									if(!running){ return false; }
									//curIndex = btns.index($(this));
									$(btns[curIndex]).addClass("on").siblings().removeClass("on");
									con.find(".slideClone").remove();
									doEffect(curIndex);
									curIndex++;
									if(curIndex==5){
										curIndex=0;
									}
								},4000);
								
								//效果函数
								var doEffect = function(curNum) {
										running = false;
										$(".intro").parent().children(".intro").hide();
										$(".intro").eq(curNum).show();
										var sliceW = Math.round(w/sliceNum)+1;
										var sliceH = Math.round(h/sliceNum)+1;
											for(var i = 0; i < sliceNum; i++){
														var curClone = con.find("li").eq(curNum).clone().appendTo(con).addClass("slideClone").css({width:0,height:sliceH,top:sliceH*i,overflow:"hidden",opacity:0,"z-index":size+1});
														curClone.find("img").css({"position":"absolute","left":"0","top":-sliceH*i})
													}
													con.find(".slideClone").each(function(n){ var ss = $(this);  setTimeout(function(){ ss.animate({ width:w,height:sliceH, opacity:"1" }, 400); }, 70*n ); 	});

										//重置z-index
										setTimeout(function(){
												for(var i=0; i<size; i++){
													if(i==curNum){ con.find("li").eq(i).css({"z-index":size}) }
													else{ con.find("li").eq(i).css({"z-index":1}) }
												}
												running=true;
										}, 70*sliceNum+400 );

								}; //Effect1 E
							});
						}
					});
				},
				getSxtzList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:71,pageSize:5},
						success: function(data) {
							that.sxtz_list = data.news_list;
							that.sxtz = data.menu;
						}
					});
				},
				getKjdtList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:65,pageSize:5},
						success: function(data) {
							that.kjdt_list = data.news_list;
							that.kjdt = data.menu;
						}
					});
				},
				getGsList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:69,pageSize:5},
						success: function(data) {
							that.gs_list = data.news_list;
							that.gs = data.menu;
						}
					});
				},
				getGbList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:64,pageSize:5},
						success: function(data) {
							that.gb_list = data.news_list;
							that.gb = data.menu;
						}
					});
				},
				getKjjsList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:46,pageSize:5},
						success: function(data) {
							that.kjjs_list = data.news_list;
							that.kjjs = data.menu;
						}
					});
				},
				getTzggList(){
					let that = this;
					$.ajax({
						type: "POST",
						url: ctx + "/getNewsData.do",
						data: {menuId:35,pageSize:10},
						success: function(data) {
							that.tzgg_list = data.news_list;
							that.tzgg = data.menu;
							that.$nextTick(function(){
								 $('#second_left').myScroll({
								        speed: 60, //数值越大，速度越慢
								        rowHeight: 40 //li的高度
								    });
							});
						}
					});
				},
			},
			mounted(){
			}
		}
		var Component = Vue.extend(Main);
		new Component().$mount('#container');
});


